import 'package:flutter/material.dart';
import 'package:flutter_component_pay/src/models/abs_third_channel.dart';
import 'package:flutter_component_pay/src/theme.dart';
import 'package:flutter_component_pay/src/utils/abs_utils.dart';

///
/// 第三方支付通道item
///
class AbsThirdPayItemView extends StatelessWidget {
  /// 支付通道模型
  final AbsThirdChannel channel;

  /// 点击item回调
  final ValueChanged<AbsThirdChannel>? onPay;

  const AbsThirdPayItemView({
    super.key,
    required this.channel,
    this.onPay,
  });

  @override
  Widget build(BuildContext context) {
    final checkBoxImage = channel.isSelected ? AbsPayTheme.checkedImage : AbsPayTheme.uncheckedImage;

    return GestureDetector(
      onTap: () => onPay?.call(channel),
      child: Container(
        color: AbsPayTheme.sheetBackgroudColor,
        padding: const EdgeInsets.only(
          left: 22,
          right: 16,
          top: 16,
          bottom: 16,
        ),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Row(
              children: [
                AbsUtils.loadImage(
                  channel.logoName,
                  size: const Size(24, 24),
                ),
                const SizedBox(width: 16),
                Text(
                  channel.payWayName,
                  style: AbsPayTheme.payTitleStyle,
                ),
              ],
            ),
            checkBoxImage,
          ],
        ),
      ),
    );
  }
}
